import java.io.*;
import java.net.*;


public class TCPServer {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
        String clientSentece;
        String capitalizedSentence;
        ServerSocket welcomeSocket = new ServerSocket(6789);
        while(true) {
            System.out.println("Servidor aguardando requisicao!");
            Socket connectionSocket = welcomeSocket.accept();
            BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
            DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
            clientSentece = inFromClient.readLine();
            capitalizedSentence = clientSentece.toUpperCase() + '\n';
            outToClient.writeBytes(capitalizedSentence);
        }
	}

}
